using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace TexasInstruments.Types.Variables {
	public class AppVar : Variable {

		/// <summary>
		/// Gets or sets the name of the program.
		/// </summary>
		public string Name {
			get {
				return Encoding.ASCII.GetString(this.RawHeader).TrimEnd('\0').Substring(1);
			}
			set {
				byte[] Result = Encoding.ASCII.GetBytes("\0" + value.PadRight(9, '\0').Remove(8));
				Result[0] = 21;
				this.RawHeader = Result;
			}
		}

		/// <summary>
		/// Gets or sets the data of the program.
		/// </summary>
		public byte[] Data {
			get {
				byte[] Result = new byte[this.RawData.Length - 2];
				Array.Copy(this.RawData, 2, Result, 0, Result.Length);
				return Result;
			}
			set {
				byte[] Result = new byte[value.Length + 2];
				Array.Copy(value, 0, Result, 2, value.Length);
				Result[0] = (byte)value.Length;
				Result[1] = (byte)(value.Length >> 8);
				this.RawData = Result;
			}
		}


	}
}
